﻿// *****************************************************************************
// **                   Ladenius MediaCenter TVSeries                         **
// ** ----------------------------------------------------------------------- **
// ** (c) 2008 by Jurjen Ladenius                                             **
// *****************************************************************************

#region Using directives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ladenius.TheTVDB.Entities;
using Ladenius.TheTVDB.Business;
#endregion

namespace Ladenius.TheTVDB {
    /// <summary>
    /// Provides entity based access to the TheTVDB XML Service
    /// </summary>
    public class TheTVDBManager {

        #region Mirror 
        /// <summary>
        /// Gets a random mirror that will return series data.
        /// </summary>
        /// <returns>a mirror</returns>
        public Mirror GetMirror_SeriesData() {
            return MirrorHome.Get_Data();
        }
        /// <summary>
        /// Gets a random mirror that will return series banners.
        /// </summary>
        /// <returns>a mirror</returns>
        public Mirror GetMirror_SeriesBanners() {
            return MirrorHome.Get_Banner();
        }
        /// <summary>
        /// Gets a random mirror that will return series files.
        /// </summary>
        /// <returns>a mirror</returns>
        public Mirror GetMirror_SeriesFiles() {
            return MirrorHome.Get_Files();
        }

        #endregion

        #region Language
        /// <summary>
        /// Gets the languages.
        /// </summary>
        /// <returns></returns>
        public List<Language> GetLanguages() {
            return LanguageHome.GetAll();
        }
        /// <summary>
        /// Gets the language by abbreviation.
        /// </summary>
        /// <returns></returns>
        public Language GetLanguageByAbbreviation(string abbreviation) {
            return LanguageHome.GetByAbbreviation(abbreviation);
        }

        #endregion

        #region Series
        /// <summary>
        /// Finds the series.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>a list of matching series.</returns>
        public List<Series> FindSeries(string name) {
            return SeriesHome.Find(name);
        }
        /// <summary>
        /// Gets the series by ID.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="language">The language.</param>
        /// <returns></returns>
        public Series GetSeriesByID(int id, Language language) {
            return SeriesHome.GetByID(id, language);
        }
        #endregion

        #region Episodes
        /// <summary>
        /// Gets the episodes by series ID.
        /// </summary>
        /// <param name="seriesID">The series ID.</param>
        /// <param name="language">The language.</param>
        /// <returns>a list of episodes</returns>
        public List<Episode> GetEpisodesBySeriesID (int seriesID, Language language) {
            return EpisodeHome.GetBySeriesID(seriesID, language);
        }
        /// <summary>
        /// Gets the episode by ID.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="language">The language.</param>
        /// <returns>an episode</returns>
        public Episode GetEpisodeByID(int id, Language language) {
            return EpisodeHome.GetByID(id, language);
        }
        /// <summary>
        /// Gets the episodes by series season.
        /// </summary>
        /// <param name="seriesID">The series ID.</param>
        /// <param name="seasonNumber">The season number.</param>
        /// <param name="language">The language.</param>
        /// <returns>a list of episodes</returns>
        public List<Episode> GetEpisodesBySeriesSeason(int seriesID, int seasonNumber, Language language) {
            return EpisodeHome.GetBySeriesSeason(seriesID, seasonNumber, language);
        }
        
        #endregion

        #region Seasons 
        /// <summary>
        /// Gets the seasons by series ID.
        /// </summary>
        /// <param name="seriesID">The series ID.</param>
        /// <param name="language">The language.</param>
        /// <returns>a list of season numbers</returns>
        public Dictionary<int, List<Episode>> GetSeasonsBySeriesID(int seriesID, Language language) {
            return SeasonHome.GetBySeriesID(seriesID, language);
        }
        /// <summary>
        /// Gets the seasons from an episode list.
        /// </summary>
        /// <param name="episodes">The episodes.</param>
        /// <returns>a list of season numbers</returns>
        public Dictionary<int, List<Episode>> GetSeasonsFromEpisodeList(List<Episode> episodes) {
            return SeasonHome.GetFromEpisodeList(episodes);
        }

        #endregion
    }
}
